#@head() 
#@header()
<title>营销管理</title>
#@aside("auxiliary")
<div class="content-wrapper">
	<section class="content">
		<div class="nav-tabs-custom">
            <ul class="nav nav-tabs">
              <li class="active"><a href="#tab_1" data-toggle="tab" aria-expanded="true">新建参数</a></li>
 
            </ul>
            <div class="tab-content">
              <div class="tab-pane active" id="tab_1">
				<div class="box-body">
					<table id="example1" style="width:800px;" class="table table-striped">
						<tbody>
							
							<tr>
								<th align="right" style="width:100px;">参数名称：</th>
								<td><input id="summary" type="text" class="form-control" placeholder="参数名称"></td>
							</tr>
							<tr>
								<th align="right" style="width:100px;">参数字段：</th>
								<td><input id="name" type="text" class="form-control" placeholder="参数字段"></td>
							</tr>
							<tr>
								<th align="right" style="width:100px;">参数值：</th>
								<td><input id="value" type="text" class="form-control" placeholder="参数值"></td>
							</tr>
						</tbody>
					</table>
				</div>
				<div class="box-footer">
					<button type="submit" id="submit" style="margin-left:10px;" class="btn btn-info ">提交</button>
				</div>
              </div>
            </div>
            <!-- /.tab-content -->
          </div>
		  
	</section>
</div>
#@footer()
<script>
$(document).ready(function(){
	var id = GetRequest(id).id;
	if(!$.isBlank(id)){
		$.getJSON("/param/info?token=#(session.token??)&id="+id, function(userli) {
			var item = userli.data.item;
			$("#summary").val(item.summary);
			$("#name").val(item.name);
			$("#value").val(item.value);
			
		});	
	}
	$("#submit").click(function() {
		layer.confirm('是否确认提交？', {btn : [ '确认', '取消' ]}, function() {
			var params = getFormVals("#tab_1");
			ajax("#(path)/param/edit?token=#(session.token??)&id="+id,params,function(data){
				if(data.code=='success'){
					layer.msg(data.msg, {icon:1,time:1000},function(){
						location.href="#(path)/admin/page/auxiliary-basicset"
					});
				}else if(data.code=='error'){
					layer.msg(data.msg, {icon:2,time:1000});
				}
			});
		}, function() {
			layer.msg('已取消！', {icon : 1});
		});
	});
	function GetRequest() {  
	   var url = location.search; //获取url中"?"符后的字串  
	   var theRequest = new Object();  
	   if (url.indexOf("?") != -1) {  
		  var str = url.substr(1);  
		  strs = str.split("&");  
		  for(var i = 0; i < strs.length; i ++) {  
			 theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);  
		  }  
	   }  
	   return theRequest;  
	}  
});
</script>
</body>
</html>

